package listeners;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class ListenerTest
 */
@WebServlet(urlPatterns = { "/ListenerTest" }, initParams = {
		@WebInitParam(name = "key1", value = "value1"),
		@WebInitParam(name = "key2", value = "value2") })
public class ListenerTest extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public ListenerTest() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		PrintWriter out = response.getWriter();
		getServletContext().setInitParameter("somekey", "somevalue");
		getServletContext().setAttribute("somekey", "somevalue");
		request.setAttribute("a", "b");
		HttpSession session = request.getSession();
		session.setAttribute("key123", "value123");
		session.setAttribute("key124", "value123");
		out.print("Hi");
		// out.print(getServletConfig().getInitParameter("key1"));

	}

}
